package com.clickpaas.workinghours.bean;

import com.bizcloud.ipaas.tbba4bf83484b4ed2aacba581fbfeac4d.  d20210220155135.model.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class WorkingHoursDTOBean {

    /**
     * 工时 TimeSheet
     * @return TimeSheetDTO
     */
    public TimeSheetDTO timeSheetDTO(){
        try {
            return getDTO(TimeSheetDTO.class);
        }catch (Exception e){
            return new TimeSheetDTO();
        }
    }

    /**
     * 工时填报 TimeCard
     * @return TimeCardDTO
     */
    public TimeCardDTO timeCardDTO (){
        try {
            return getDTO(TimeCardDTO.class);
        }catch (Exception e){
            return new TimeCardDTO();
        }
    }

    /**
     * 工时填报 TimeCard
     * @return TimeCardDTOQuery
     */
    public TimeCardDTOQuery timeCardDTOQuery (){
        try {
            return getDTO(TimeCardDTOQuery.class);
        }catch (Exception e){
            return new TimeCardDTOQuery();
        }
    }

    /**
     * 工时填报 TimeCard
     * @return TimeCardDTOUpdate
     */
    public TimeCardDTOUpdate timeCardDTOUpdate (){
        try {
            return getDTO(TimeCardDTOUpdate.class);
        }catch (Exception e){
            return new TimeCardDTOUpdate();
        }
    }

    /**
     * 工时填报 TimeCard
     * @return TimeCardDTODelete
     */
    public TimeCardDTODelete timeCardDTODelete (){
        try {
            return getDTO(TimeCardDTODelete.class);
        }catch (Exception e){
            return new TimeCardDTODelete();
        }
    }

    /**
     * 工时填报 TimeCard
     * @return TimeCardDTOPageInfo
     */
    public TimeCardDTOPageInfo timeCardDTOPageInfo (){
        try {
            return getDTO(TimeCardDTOPageInfo.class);
        }catch (Exception e){
            return new TimeCardDTOPageInfo();
        }
    }

    /**
     * 对象名称:工时日期
     * 对象代码:TimeCardDate
     * @return TimeCardDateDTO
     */
    public TimeCardDateDTO timeCardDateDTO (){
        try {
            return getDTO(TimeCardDateDTO.class);
        }catch (Exception e){
            return new TimeCardDateDTO();
        }
    }

    /**
     * 对象名称:工时日期
     * 对象代码:TimeCardDate
     * @return TimeCardDateDTOQuery
     */
    public TimeCardDateDTOQuery timeCardDateDTOQuery (){
        try {
            return getDTO(TimeCardDateDTOQuery.class);
        }catch (Exception e){
            return new TimeCardDateDTOQuery();
        }
    }

    /**
     * 对象名称:工时日期
     * 对象代码:TimeCardDate
     * @return TimeCardDateDTOUpdate
     */
    public TimeCardDateDTOUpdate timeCardDateDTOUpdate (){
        try {
            return getDTO(TimeCardDateDTOUpdate.class);
        }catch (Exception e){
            return new TimeCardDateDTOUpdate();
        }
    }

    /**
     * 项目 project
     * @return ProjectDTO
     */
    public PMSprojectDTO pmSprojectDTO(){
        try {
            return getDTO(PMSprojectDTO.class);
        }catch (Exception e){
            return new PMSprojectDTO();
        }
    }

    /**
     * 项目 project
     * @return ProjectDTOPageInfo
     */
    public PMSprojectDTOPageInfo pmSprojectDTOPageInfo(){
        try {
            return getDTO(PMSprojectDTOPageInfo.class);
        }catch (Exception e){
            return new PMSprojectDTOPageInfo();
        }
    }

    /**
     * 商机 opportunity
     * @return OpportunityDTO
     */
    public OpportunityDTO opportunityDTO(){
        try {
            return getDTO(OpportunityDTO.class);
        }catch (Exception e){
            return new OpportunityDTO();
        }
    }

    /**
     * 商机 opportunity
     * @return OpportunityDTOPageInfo
     */
    public OpportunityDTOPageInfo opportunityDTOPageInfo(){
        try {
            return getDTO(OpportunityDTOPageInfo.class);
        }catch (Exception e){
            return new OpportunityDTOPageInfo();
        }
    }

    /**
     * 市场活动 Campaign
     * @return CampaignDTO
     */
    public CampaignDTO campaignDTO(){
        try {
            return getDTO(CampaignDTO.class);
        }catch (Exception e){
            return new CampaignDTO();
        }
    }

    /**
     * 市场活动 Campaign
     * @return CampaignDTOPageInfo
     */
    public CampaignDTOPageInfo campaignDTOPageInfo(){
        try {
            return getDTO(CampaignDTOPageInfo.class);
        }catch (Exception e){
            return new CampaignDTOPageInfo();
        }
    }

    /**
     * WBS WBS
     * @return WBSDTO
     */
    public WBSDTO wbsdto(){
        try {
            return getDTO(WBSDTO.class);
        }catch (Exception e){
            return new WBSDTO();
        }
    }

    /**
     * Lead 线索
     * @return LeadDTO
     */
    public LeadDTO leaddto(){
        try {
            return getDTO(LeadDTO.class);
        }catch (Exception e){
            return new LeadDTO();
        }
    }

    /**
     * Lead 线索
     * @return LeadDTOQuery
     */
    public LeadDTOQuery leadDTOQuery (){
        try {
            return getDTO(LeadDTOQuery.class);
        }catch (Exception e){
            return new LeadDTOQuery();
        }
    }

    /**
     * Lead 线索
     * @return LeadDTOUpdate
     */
    public LeadDTOUpdate leadDTOUpdate (){
        try {
            return getDTO(LeadDTOUpdate.class);
        }catch (Exception e){
            return new LeadDTOUpdate();
        }
    }

    /**
     * Lead 线索
     * @return LeadDTODelete
     */
    public LeadDTODelete leadDTODelete(){
        try {
            return getDTO(LeadDTODelete.class);
        }catch (Exception e){
            return new LeadDTODelete();
        }
    }

    /**
     * 获取沙箱ID
     * @param clazz
     * @param <T>
     * @return
     * @throws Exception
     */
    private  <T> T getDTO(Class<T> clazz) throws Exception {
        T t = (T) clazz.newInstance();
        //TODO下个版本更新沙箱ID
        /*Method setatsandboxDBId = null;
        try {
            setatsandboxDBId = t.getClass().getDeclaredMethod(ConstantFile._SET_AT_SANDBOXDB_ID, String.class);
            if (StringUtils.isNotBlank(AutoLoadConfig.SANDBOX_ID)){
                setatsandboxDBId.invoke(t,AutoLoadConfig.SANDBOX_ID);
            }
        }catch (Exception e){
            log.info("对象【{}】获取沙箱ID失败！",t);
            return (T) t;
        }*/
        return (T) t;
    }

}
